home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 6_17.lha / 6_17 / 6_17a20.c < prev    next >
C/C++ Source or Header  |  1993-08-08  |  382b  |  17 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. / x = v1.dot(v2)
  6. include <minmax.h>
  7. loat vector::dot(vector& v2)
  8.  
  9.    int l = min(p->length, v2.p->length);
  10.    float sum = 0;
  11.    float *f1 = p->f;
  12.    float *f2 = v2.p->f;
  13.    for (int i = 0; i < l; i++)
  14. sum += *f1++ * *f2++;
  15.    return sum;
  16.  
  17.